package com.ctaa.ctaa.controller;

import com.ctaa.ctaa.dto.Result;
import com.ctaa.ctaa.pojo.AnalysisPojo;
import com.ctaa.ctaa.pojo.CategoryPojo;
import com.ctaa.ctaa.pojo.MonthlyStatisticsPojo;
import com.ctaa.ctaa.service.AnalysisService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 统计分析
 */
@RestController
@RequestMapping("analysis")
public class AnalysisController {

    @Resource
    AnalysisService analysisService;

    //查询今日消费清情况，今日支出、收入、结余
    @GetMapping("daySum")
    public Result<AnalysisPojo> searchDaySum(Integer userId) {
        return analysisService.searchDaySum(userId);
    }

    /**
     * 查询年度、类型查询统计
     */

    //总的支出收入结余
    @GetMapping("yearSum")
    public Result<AnalysisPojo> searchYearSum(Integer userId, Integer year) {
        return analysisService.searchYearSum(userId, year);
    }

    //通过类别查询支出、收入
    @GetMapping("categorySum")
    public Result<List<CategoryPojo>> searchCategory(Integer userId, Integer year, Integer type) {
        return analysisService.searchCategory(userId, year, type);
    }

    //按月份查询收支情况
    @GetMapping("monthSum")
    public Result<List<MonthlyStatisticsPojo>> searchMonthSum(Integer userId, Integer year) {
        return analysisService.searchMonthSum(userId, year);
    }

    //查询目前数据所有年份
    @GetMapping("searchYear")
    public Result<List<String>> searchYear(Integer userId) {
        return analysisService.searchYear(userId);
    }

}
